import numpy as np
from SAGIN_Progrem.entity.Task import Task
import random
import pandas as pd
from SAGIN_Progrem.entity.Formulas import Formulas

# 地面传感器
class Appliances:

    B = 1000000  # 带宽1MHz
    P = 30  # 传输功率 30dBm
    f = 1
    formulas = Formulas(B, P, f)

    coordinates_x_y = []
    def __init__(self, id):
        self.id = id
        self.task_app_one_list = self.create_Task()
        self.flag = False # 传感器被无人机覆盖为True，否则为False
        self.coordinates_x_y = []

    # 随机生成1~6个任务
    def create_Task(self):
        count = random.randrange(5, 9, 1)
        #task = Task()
        # task_queue = np.array([])
        #task_row = [task.size, task.complex, task.prior, task.delay_tolerate]
        task_row = []
        # print(task_row)
        #task_queue = np.array(task_row, dtype='float32')
        # print(task_queue)
        for i in range(60):
            id = str(self.id) + str(i)
            task = Task(id, self.id)
            #task_row1 = [task1.size, task1.complex, task1.prior, task1.delay_tolerate]
            #task_queue = np.append(task_queue, task_row1)
            task_row.append(task)
        #task_queue = task_queue.reshape(int(len(task_queue) / 4), 4)
        return task_row

    def setcoor(self, new_coor):
        self.coordinates_x_y = new_coor


    # 向卫星卸载任务



if __name__ == '__main__':
    app = Appliances(5)
    print(app.task_app_one_list)
    print(app.task_app_one_list[0].id)
    print(app.task_app_one_list[0].size)
    # 生成横坐标 x 在范围 [0, 1000) 内的随机数
    x = random.uniform(0, 1000)
    # 生成纵坐标 y 在范围 [0, 1000) 内的随机数
    y = random.uniform(0, 1000)
